<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" type="text/css" href="<%=path %>/static/css/css.css?1" />
<link rel="stylesheet" type="text/css" href="<%=path %>/static/jquery-ui/jquery-ui.min.css" />
<script type="text/javascript" src="<%=path %>/static/js/json2.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/static/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="<%=path %>/static/layer/layer.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/gridview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/formview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/tool.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/validate.js"></script>
<script type="text/javascript" src="<%=path %>/wechat/js/copy/ZeroClipboard.js"></script>
<style>
   .mtable th[name=userType],.mtable td[name=userType]{
      display:none;
   }
</style>
<SCRIPT type="text/javascript">
    <!--
	var gridSetting = {
			id:'QhNoticeGrid',
			po:"QhNotice",
			title:'公告列表',
			height:'auto',
			service:"uiServices!listSimple",
			tbId:"NoticeTb",
			pageInfo: {
				records: 12,//auto表示根据容器高度自动判断
				orderby : "id desc"
			},
			oper:{
                isDisplay:false,
            	operName:"",
            	url:"",
            	cssClass:"Operation",
            	width:120
            },
			fields:[
			   {	name:'id',
					hide:true
			   },{
                    name: 'uid',
                    descs:"接收人",
                    align:'left',
                    thstyle:"width:180px"
               }
			   ,{
                   name: 'type',
                   descs:"类型",
                   thstyle:"width:80px"
               },
               {
				   name: 'title',
				   descs:"标题",
				   align:'left'
			   },
               {
               	   name: 'userType',
               	   descs:"",
               	   align:'left'
               }
			]
		};
	var grid;
    $(document).ready(function(){
    	grid = new GridView("list",gridSetting,"list");
		grid.init();
		var data = [];
		var uid="${param.uid}";
        if(uid!==""){
           data.push({or:[{r:"=",name:'uid',value:uid},{r:"=",name:'uid',value:"all"}]});
        }
        else{
           data.push({r:"=",name:'type',value:"系统消息"});
        }
		grid.load({data:data});

		if(uid!==""){
		   $("th[name=uid]").hide();
           $("td[name=uid]").hide();
		}

		ajustHeight();

		$("#addBtn").click(function(){
        	location.href="/qh/public/common/r2.htmls?page=notice/notice_edit";
        });

        $("#delBtn").click(function(){
        	grid.deletes("deleteMappedRoleNavis",function(ret){
                if(ret==-1){
                    layer.msg("删除失败，请重试！");
                }else{
                    layer.msg("删除" + ret.recordNum + "条记录！",function(ret){
                        grid.reload();
                    });
                }
            });
        });

    });

    //-->
</SCRIPT>
</head>

<body>
<ul class=tab_nav>
  <li>
    <a class="current" href="javascript:void(0)">系统公告</a>
  </li>
</ul>
<div class="contrainer">
<div class="rcon2" >
<table class="search_tb">
   <tr>
      <td style="padding-left:15px;">
         <input style="float:left" type="text" name="title" placeholder="标题" />
         <input type="button" class="searchbtn" value="" id="queryBtn">
      </td>
      <td>

      </td>
      <td>
         <input type="button" class="btnblue" value="新增" id="addBtn" >
         <input type="button" class="btnblue" value="删除" id="delBtn"" >
      </td>
   </tr>
</table>
</div>
<div id="formview" class="rbox1"></div>
<div id="list" class="rbox2"></div>
</div>
<script type="text/javascript" src="<%=path %>/static/js/underscore.js"></script>
<script type='text/javascript' src='<%=path %>/static/My97DatePicker/WdatePicker.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/interface/BaseDwr.js'></script>
<script>
    $("#queryBtn").click(function(){
       var Title = $(".search_tb").find(":input[name=title]").val();

       var data = [];
       var uid="${param.uid}";
       if(uid!==""){
          data.push({or:[{r:"=",name:'uid',value:uid},{r:"=",name:'uid',value:"all"}]});
       }
       else{
          data.push({r:"=",name:'type',value:"系统消息"});
       }
       if(Title!==""){
          data.push({r:"like",name:'title',value:"%"+Title+"%"});
       }

       grid.load({data:data});
       ajustHeight();
    });

    function afterLoad_NoticeTb(){
       $(".rcon2 .mtable tbody tr").each(function(){
          var uid=$(this).find("td[name=uid]");

          if(uid.text()=="all"){
             uid.text("所有用户");
          }
          else{
             var id=$(this).attr("recordid");
             var userType=$(this).find("td[name=userType]").text();
             if(userType=="a"){
                $.getJSON(g_path+"/public/common/getUserName.htmls",{uid:uid.text()},function(ret){
                   uid.html("<a href='/qh/public/common/r2.htmls?page=notice/notice_view&id="+id+"'>"+ret.data+"</a>");
                });
             }
             else{
                $.getJSON(g_path+"/public/common/getAdverName.htmls",{uid:uid.text()},function(ret){
                   uid.html("<a href='/qh/public/common/r2.htmls?page=notice/notice_view&id="+id+"'>"+ret.name+"</a>");
                });
             }
          }
       });

    }

</script>
</body>
</html>